﻿/*  ----------------------------------------------------------------------------
 *  SysServer
 *  ----------------------------------------------------------------------------
 *  File:       IncomingDataPreparer.cs
 *  Creater:     SEEN\MistSeen
 *  ----------------------------------------------------------------------------
 *  $Date: 2010-09-06 10:36:01 +0000 (Mon, 06 Sep 2010) $
 *  $Rev: 15 $
 *  $Author: ScorDeity $
 *  $URL: http://sysserver.googlecode.com/svn/trunk/src/SysServer/Sock/IncomingDataPreparer.cs $
 *  $Id: IncomingDataPreparer.cs 15 2010-09-06 10:36:01Z ScorDeity $
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace SysServer.Sock
{
    using System.Net.Sockets;
    using System.Net;
    class IncomingDataPreparer
    {
        private DataEntity _DataEntity;
        private SocketAsyncEventArgs _ReceiveEventArg;

        public IncomingDataPreparer(SocketAsyncEventArgs receiveEventArg)
        {
            this._ReceiveEventArg = receiveEventArg;
        }
        public int ReceivedTransMissionId
        {
            get
            {
                return 0;
            }
        }
        private EndPoint RemoteEndpoint
        {
            get
            {
                return this._ReceiveEventArg.AcceptSocket.RemoteEndPoint;
            }
        }
        public DataEntity HandleReceivedData(DataEntity incomeDataEntity )
        {
            var receiveToken = (DataEntityUserToken)this._ReceiveEventArg.UserToken;
            this._DataEntity = incomeDataEntity;
            this._DataEntity.SessionId = receiveToken.SessionId;
            this._DataEntity.ReceivedTransMissionId = this.ReceivedTransMissionId;
            this._DataEntity.RemoteEndPoint = this.RemoteEndpoint;

            return _DataEntity;
        }
    }
}